import { forwardRef,useImperativeHandle } from "react";
const UseRefChild = forwardRef((props, _ref) => {
   
    console.log('来自父组件的数据', _ref.current,props)
    const msg = 'hello'
    useImperativeHandle(_ref, () => {
        console.log('useImperativeHandle', _ref)
        return {
            name: 'zhangsan',
            fallBack: () => {
               console.log('这是暴露给外界用的方法')
            },
            getMsg: () => {
                console.log('组件保留给外界访问的msg',msg)
            }
        
        }
    
    })
    return (<div>
     useRef子组件内容..<br/>
     <h3>props获取父组件传过来的数据</h3>
     <ul>
        {
         props.list.list.map((item,key) => <p key={key}>{item.name}</p>)
        }
     </ul>
     <button onClick={() => props.updateList({name: 'abc'})}>更新list</button>
    </div> );
})
 
export default UseRefChild;